//
// Created by Administrator on 2021/7/2.
//
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

class Solution {
public:
    /**
     * 总是先拿最便宜的
     */
    int maxIceCream(vector<int>& costs, int coins) {
        sort(costs.begin(),costs.end());
        int ans = 0;
        for(int cost : costs){
            coins -= cost;
            if (coins>=0) ++ ans;
            else break;
        }
        return ans;
    }
};

int main()
{
//    vector<int>costs{1,3,2,4,1};
//    vector<int>costs{10,6,8,7,7,8};
    vector<int>costs{1,6,3,1,2,5};
    Solution sol;
    cout << sol.maxIceCream(costs,20);
    return 0;
}